/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.rpc;

import com.comac.ins.isfd.rpc.isfd.oauth.IsfdOauthInterceptor;
import com.comac.ins.isfd.rpc.simright.SimrightOauthInterceptor;
import com.comac.ins.isfd.rpc.xuelang.XueLangOauthInterceptor;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.util.Collections;

@Configuration
public class RestTemplateConfig {

    @Bean
    public RestTemplate tokenRestTemplate() {
        return new RestTemplate();
    }

    @Bean
    public RestTemplate isfdRestTemplate(IsfdOauthInterceptor isfdOauthInterceptor) {
        return new RestTemplateBuilder()
            .interceptors(Collections.singletonList(isfdOauthInterceptor))
            .build();
    }

    @Bean
    public RestTemplate xueLangRestTemplate(XueLangOauthInterceptor xueLangOauthInterceptor) {
        return new RestTemplateBuilder()
            .interceptors(Collections.singletonList(xueLangOauthInterceptor))
            .build();
    }

    @Bean
    public RestTemplate simrightRestTemplate(SimrightOauthInterceptor simrightOauthInterceptor){
        return new RestTemplateBuilder()
            .interceptors(Collections.singletonList(simrightOauthInterceptor))
            .build();
    }
}
